use std::cell::{Cell, RefCell};
use std::mem;
use std::rc::Rc;

// size_of 返回通过泛型获得的类型大小
// size_of_val 返回某个引用值的大小
fn main() {
    println!("type u8: {}", mem::size_of::<u8>());
    println!("type f64: {}", mem::size_of::<f64>());

    println!("value 4u8: {}", mem::size_of_val(&4u8));
    println!("value 4: {}", mem::size_of_val(&4));
    println!("value 'a': {}", mem::size_of_val(&'a'));

    println!("value \"Hello World\" as a static str slice: {}", mem::size_of_val("Hello World"));
    println!("value \"Hello World\" as a String: {}", mem::size_of_val("Hello World").to_string());

    println!("Cell(4)): {}", mem::size_of_val(&Cell::new(84)));
    println!("RefCell(4)): {}", mem::size_of_val(&RefCell::new(4)));

    println!("Rc(4): {}", mem::size_of_val(&Rc::new(4)));
    println!("Rc<RefCell(4)>): {}", mem::size_of_val(&Rc::new(RefCell::new(4))));
}